package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * @Author：无敌暴龙战士
 * @Package：org.example.controller
 * @Project：learn_spring_security
 * @name：LoginUserController
 * @Date：2025/2/12 3:06
 * @Filename：LoginUserController
 * @Description:
 */
@RestController
@Slf4j
public class LoginUserController {

    @GetMapping("/getUserLogin")
    public Authentication get(Authentication authentication) {
        return authentication;
    }

    @GetMapping("/getUserLogin2")
    public Principal get2(Principal principal) {
        return principal;
    }

    @GetMapping("/getUserLogin3")
    public Principal get3() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return authentication;
    }



}
